#coding:utf-8

# 一、数值 + 操作符 = 表达式--------------------------------------------
# 1.乘法优先
a = 2 + 3 * 6
print a

# 2.括号优先
b = (2 +3) * 6
print b

# 3.整型
c = 234234234 * 234234
print c

# 4.指数
d = 2 ** 8
print d

# 5.除法求整
e = 23 // 7
print e

# 6.除法求余
f = 23 % 7
print f

# 7.各种括号
g = (5 - 1) * ((7 + 1) / (3 - 1))
print g

# 二、字符操作--------------------------------------------
# 1.连接字符
a = 'Alice' + 'Bob'
print a

# 2.复制字符
b = 'Alice' * 5
print b

# 三、值 + 等号 = 赋值--------------------------------------------
# 1.赋值后的变量相加
spam = 40
eggs = 2
a = spam + eggs + spam
print a

# 2.迭代相加不同表示
spam = spam + 2
spam += 2

# 四、函数使用--------------------------------------------
# 1.len()字符长度
a = len('hello world!')
print a

# 2.str()转字符类型
b = str(2)
print b

# 3.int()转整型
c = int('42')
print c
c = int(1.2)
print c

# 3.float()转浮点类型
d = float(32)
print d
d = float('3.111')
print d

# 4.hex()转16进制
e = hex(11442233)
print e

# 5.oct()转8进制
f = oct(11442233)
print f

# 五、其他情况--------------------------------------------
# 1.字符不能等于数字
a = 42 == '42'
print a

# 2.字符型的浮点类型不能转整型
try:
    int('99.99')
    print('True')
except:
    print 'False'

# 3.字符型的字符类型不能转整型
try:
    int('test')
    print('True')
except:
    print 'False'


# 六、布尔类型--------------------------------------------
# 1.==等于
a = 42 == 42
print a

# 2.!=不等于
a = 40 != 42
print a

# 3.<小于
a = 40 < 42
print a

# 4.>大于
a = 42 > 40
print a

# 5.<=小于等于
a = 42 <= 42
print a

# 6.>=大于等于
a = 42 >= 40
print a

# 7.and操作符的真值表
a = True and True
print a
a = True and False
print a
a = False and True
print a
a = False and False
print a

# 8.or操作符的真值表
a = True or False
print a
a = True or False
print a
a = False or True
print a
a = False or False
print a

# 9. not操作符
a = not True
print a
a= not False
print a

# 10.混合布尔操作符
print (4 < 5) and (5 < 6)
print (1 == 2) or (2 == 2)

# 七、控制流语句--------------------------------------------
# 1.if 语句
name = 'Alice'
if name == 'Alice':
    print 'Hi, Alice!'

# 2.else语句
name = 'Bob'
if name == 'Alice':
    print 'Hi, Alice!'
else:
    print 'Hi Bob!'

# 3.elif语句
name = 'Lucy'
if name == 'Alice':
    print 'Hi, Alice!'
elif name == 'Lucy':
    print 'Hi Lucy!'

# 4.while语句
spam = 0
while spam < 5:
    print 'Hello World!'
    spam += 1